new Vue({
	el: '#main',
	data: {
		imageFile: [
		{src:"../../img/active/img@3x.png"}
		],
		attentList:[],
		attentPerson:"",
		phone:"",
		address:"",
		position:"",
		currentWebview:''
	},
	methods: {
		plusReady: function() {
			var context = this;
			this.currentWebview = plus.webview.currentWebview();
			//查询会议报名信息
			var data = {
//				meetingId:this.currentWebview.id,
				meetingId:'12d3200031754d3dbf48f84e5bca135d',
			};
			ajAjax("app/meeting/getApplyInfo.do", data, function(data) {
				context.attentList  = data.Rows.enterUserList
			}, function(err) {
				mui.toast('查询会议报名信息失败')
			});
		},
		choosePerson:function(e,item){
			if(e.currentTarget.classList=="mui-icon icon-checkbox mui-pull-right"){
				e.currentTarget.classList.add('mui-active');
				this.attentPerson += item.enterUser+",";
			}else{
				e.currentTarget.classList.remove('mui-active');
				this.attentPerson.replace(item.enterUser,"");
				this.attentPerson.replace(/(^,)($,)/,"");
				console.log(this.attentPerson)
			}
		},
		choiceImgFunc:function(item,index){
			var context = this;
//			this.activeIndex = index;
			var btnArray = [{
				title: "拍照"
			}, {
				title: "从相册选择"
			}];
			plus.nativeUI.actionSheet({
				title: "选择照片",
				cancel: "取消",
				buttons: btnArray
			}, function(e) {
				var index = e.index;
				switch(index) {
					case 0:
						break;
					case 1: //拍照，返回一个相对路径
						var cmr = plus.camera.getCamera();
						cmr.captureImage(function(p) {
							//把相对路径转为绝对路径，
							plus.io.resolveLocalFileSystemURL(p, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
							}, function(e) {

							});

						}, function(e) {

						});
						break;
					case 2: //相册
						plus.gallery.pick(function(path) {
							plus.io.resolveLocalFileSystemURL(path, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
							}, function(e) {

							});
						}, function(err) {

						}, { filter: "image" });
						break;
				}
			});

		},
		submit: function() {
			if(!this.address){
				mui.toast("请输入联系地址");
				return
			};
			if(!this.position){
				mui.toast("请输入职位");
				return
			};
			if(!this.attentPerson){
				mui.toast("请选择参会人员");
				return
			};
			if(!this.name){
				mui.toast("请输入姓名");
				return
			};
			if(!this.phone){
				mui.toast("请输入手机号");
				return
			};
			if(this.image.length==0){
				mui.toast("请上传报名材料");
				return
			};
			if(!isTelPhone(this.phone)){
				mui.toast("请输入正确的手机号");
				return
			};
			var  context=this;
			var datajson = {
//				meetingId:this.currentWebview.id,
				meetingId:'12d3200031754d3dbf48f84e5bca135d',
				userIds:this.attentPerson,
				image:'2233'
			};
			ajAjax("app/meeting/orgApply.do", datajson, function(data) {
				mui.toast('报名成功')
			}, function(err) {
				mui.toast('报名失败')
			});
		},
		cancle:function(){
			var datajson = {
				meetingId:this.currentWebview.id
			};
			ajAjax("app/meeting/deleteOrgApply.do", datajson, function(data) {
				mui.toast('取消报名成功')
			}, function(err) {
				mui.toast('取消报名失败')
			});
		}
	},
	mounted: function() {
		var context = this;
//			this.currentWebview = plus.webview.currentWebview();
			//查询会议报名信息
			var datajson = {
//				meetingId:this.currentWebview.id,
				meetingId:'12d3200031754d3dbf48f84e5bca135d',
			};
			ajAjax("app/meeting/getApplyInfo.do", datajson, function(data) {
				context.attentList  = data.Rows.enterUserList
			}, function(err) {
				mui.toast('查询会议报名信息失败')
			});
//		if(window.plus) {
//			this.plusReady();
//		} else {
//			document.addEventListener("plusready", this.plusReady, false);
//		}
	}
});